package com.heima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.common.PageResult;
import com.heima.mapper.TaskMapper;
import com.heima.mapper.TaskStatusTypeMapper;
import com.heima.pojo.Task;
import com.heima.pojo.TaskStatusType;
import com.heima.pojo.vo.TaskVo;
import com.heima.service.ITaskStatusTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service
public class TaskStatusTypeServiceImpl extends ServiceImpl<TaskStatusTypeMapper, TaskStatusType> implements ITaskStatusTypeService {
    @Autowired
    private TaskMapper taskMapper;

    @Override
    public List<Map<String, Object>> top10() {
        return taskMapper.top10();
    }

    @Override
    public PageResult<TaskVo> trouble(PageResult<TaskVo> pageResult) {
        Page<Task> page = new Page<>(pageResult.getPageIndex(), pageResult.getPageSize());
        QueryWrapper<Task> queryWrapper = new QueryWrapper<>();
        pageResult.setTotalPage(String.valueOf(page.getPages()));
        pageResult.setTotalCount(String.valueOf(page.getTotal()));
        return pageResult;
    }
}
